<?php
include './application/views/common/zhs_header.php';
?>
<!-- center部分 -->
<?php
include './application/views/common/zhs_usercenter_acnt.php';
?>
<div class="inv_box w">
<?php
include './application/views/common/zhs_usercenter_left.php';
?>
  <div class="membd_right">
<h3 class="membdrg_tit">银行卡管理</h3>
        
        <?php if(isset($bank0)){ ?>
        <ul class="membank_bd">
	<li class="bank_top">
	<h3><?php echo $bank_list [$bank0['bank']];?></h3>
	<a href="#">已绑定</a></li>
	<li class="bank_bd">
            卡号：<?php echo strdisplay ( $bank0['account'], 0 ); ?><br>
			户名：<?php echo strdisplay ( $user ['realname'], 0 ); ?><br>
			开户支行：<?php echo isset ( $bank0['province'] ) ? $area [$bank0 ['province']] : ''; ?>
			<?php echo isset ( $bank0['city'] ) ? $area [$bank0['city']] : ''; ?>
			<?php echo isset ( $bank0['area'] ) ? $area [$bank0['area']] : ''; ?>
			<?php echo $bank0['branch']; ?>
	</li>
	<li class="bank_top"><a href="javascript:;" onclick="delete_bank('<?php echo $bank0['id'];?>')">删除</a>
	
           <?php if ($bank0 ['default_flag'] == 1) { ?>
           		默认
           	<?php } ?>
           	</li>
       </ul>    	

       <?php }
       if(isset($bank1)){ ?>
        <ul class="membank_bd">
	<li class="bank_top">
	<h3><?php echo $bank_list [$bank1['bank']]; ?></h3>
	<a href="#">已绑定</a></li>
	<li class="bank_bd">卡号：<?php echo strdisplay ( $bank1['account'], 4 ); ?><br>
			户名：<?php echo strdisplay ( $user ['realname'], 1 ); ?><br>
			开户支行：<?php echo isset ( $bank1['province'] ) ? $area [$bank1 ['province']] : ''; ?>
			<?php echo isset ( $bank1['city'] ) ? $area [$bank1['city']] : ''; ?>
			<?php echo isset ( $bank1['area'] ) ? $area [$bank1['area']] : ''; ?>
			<?php echo $bank1['branch']; ?>
	</li>
	<li class="bank_top"><a href="javascript:;" onclick="delete_bank('<?php echo $bank1['id'];?>')">删除</a>
           <?php if ($bank1 ['default_flag'] == 1) { ?>
           		默认
           	<?php } ?>
           	</li>

       <?php }
	 	if (!isset($bank1)) { ?>
        </ul>

<ul class="membank_bd">
	<dl>
		<dt><a href="javascript:;" onclick="addbank();"><img
			src="<?php echo CON_STATIC_URL; ?>/zhsjr/images/con_21.gif"></a></dt>
		<dd><a href="javascript:;" onclick="addbank();">添加一张银行卡</a></dd>
	</dl>
</ul>
        <?php } ?>
  </div>
<form id="myform" >
 <input type="hidden" id='typer' name="typer" value="add">  
	<br>
<br>
<div id="addbank" style="display: none;" class="membd_right">
<ul class="perboxul">
	<li><span>开户姓名：</span><p ><?php
	echo strdisplay ( $user ['realname'], 1 );
	?></p></li>
	<li><span>开户银行：</span><p><select id='bank' name="bank">
					<?php
					foreach ( $bank_list as $k => $v ) {
						?>
						<option value="<?php
						echo $k;
						?>"><?php
						echo $v;
						?></option>
					<?php
					}
					?>
					</select></p></li>
	<li><span>开户行所在地：</span><p> <select name="province" id="province"
		onchange="changeCity(this.value,'city');">
		<option value="">请选择</option>
	</select> </select> <select id='city' name="city"
		onchange="changeCity(this.value,'area');">
		<option value="">请选择</option>
	</select> <select id='area' name="area">
		<option value="">请选择</option>
	</select></p></li>
	<li><span>开户支行：</span><p style="*margin-left:6px;"><input  type="text" id='branch' name="branch" value=""
		size="20" /></p></li>
	<li><span>银行账号：</span><p style="*margin-left:6px;"><input type="text" name="account" id='account' value=""
		size="20" /></p></li>

	<li><span>设置默认：</span><p>
	<input type="checkbox" class="lf" name="default_flag" value="1" id="default_flag"  <?php if(!isset($bank0)){ echo "checked disabled"; } elseif($bank0['default_flag'] != 1){echo "checked disabled"; }?>>
	</p></li>
	<!--
	<li><span>验证码：</span><p><p style="*margin-left:6px;"><input type="text" value="" name="ve_code" maxlength="12"> <div

		id="phone_code"> <input type="button" value="获取验证码"
		onclick="peSubmit();"> </div></p></li>
		-->
	<li><input type="button" class="little_button" style="margin-left:126px;" size="30" value="确认提交"
		onclick="toSubmit();"></li>
</ul>


</div>
</form>
<script type="text/javascript">
$(document).ready(function(){
	getArea(0,'','province');
});
function addbank(){
	<?php if($real_status == '1'){?>
	var addbank=document.getElementById('addbank');
	addbank.style.display="block";
<?php } else{ ?>
	if(confirm("请实名认证之后添加银行卡！")){
			window.location.href='/user/zhs_realname.html';
	}
<?php }?>
}

function changeCity(a,obj){
	var msg = "<option value=''>请选择</option>";
	if(a!=''){
		getArea(a,'',obj);
		if(obj=='city'){
			$("#area").html(msg);
		}
	}else{
		if(obj=='city'){
			$("#city").html(msg);
			$("#area").html(msg);
		}
	}
	
}
function getArea(pid, selected, obj){
	$.ajax({
		type: "POST",
		url: "/area/get_option",
		data: "pid="+pid+"&selected="+selected,
		success: function(msg){
			$("#"+obj).html(msg);
			if(arry[2]!=null && arry[2] != ''){
				$("#city").val(arry[2]);
				arry[2] = '';
			}
			if(arry[3]!=null && arry[3] != ''){
				$("#area").val(arry[3]);
				arry[2] = '';
			}
		},
		dataType: "text"
	});
}

function toSubmit(){
	$('#dialog').dialog({
		modal:true,
		title:'系统提示',
		buttons:{"确定":function(){
			var options = {
				url : GetUrlRelativePath(),
				dataType: "text",
				type:"post",
				success : function(ret) {
					if(ret == ''){
						mesinfo = "提交成功";
					}
					else{
						mesinfo = ret;
					}
					$('#dialog').dialog({
						modal:true,
						title:'系统提示',
						buttons:{"确定":function(){$(this).dialog("close");}},
						close: function() {
							if(ret==''){
								window.location='/account/zhs_bank';
							}
						}
					}); 
					$("#msg").html(mesinfo);
				}
			};
			$("#myform").ajaxSubmit(options);
		},
		"取消":function(){$(this).dialog("close");}}
	}); 
	$("#msg").html("您现在填写的是提现账号，您从平台上的提现皆转入此账户，请仔细核对，账户名必须与您实名认证的名字一致，否则可能致使提现失败");
	return false;
}
function delete_bank(id){
	$.ajax({
		type: "post",
		url: "/reg/sendsms.html",
		success: function(ret){
			if(ret.info == 1){
				
			}else{
				
			}
		},
		dataType: "json"
	});	
	$('#dialog').dialog({
		modal:true,
		title:'系统提示',
		buttons:{"确定":function(){
				$.ajax({
					type: "post",
					url: "/account/zhs_delete_bank.html",
					data: "bank_id="+id+"&ve_code="+$("#ve_code").val(),
					success: function(ret){
						if(ret == ''){
							mesinfo = "删除成功";
						}
						else mesinfo = ret;
						$('#dialog').dialog({
							modal:true,
							title:'系统提示',
							buttons:{"确定":function(){$(this).dialog("close");}},
							close: function() {
								if(ret==''){
									window.location='/account/zhs_bank';
								}
							}
						}); 
						$("#msg").html(mesinfo);
						
					},
					dataType: "text"
				});	
		},
		"取消":function(){$(this).dialog("close");}}
	}); 
	$("#msg").html("<span>请查看手机并输入收到的验证码：</span><p><p style=\"*margin-left:6px;\"><input type=\"text\" id='ve_code' name=\"ve_code\" maxlength=\"6\">");
	return false;
}
function peSubmit(){
	$("#phone_code").html('处理中，请等待');
	$.ajax({
		type: "post",
		url: "/user/submit_bind_code.html",
		success: function(ret){
			if(ret.info == 1){
				phone_countdown();
			}else{
				$("#phone_code").html(ret.msg);
				setTimeout(function(){
				$("#phone_code").html('<a href="javascript:;" onclick="peSubmit();" style="color:#a71e32; margin-top:0; text-decoration:underline"> 重新获取手机验证码</a>');
					
				},3000);
			}
		},
		dataType: "json"
	});	
}
function phone_countdown(){
	var count = 180;
	var countdown = setInterval(CountDown, 1000); 
	function CountDown() {
		$("#phone_code").html('手机验证码已发送,请等待 <font style="color:#a71e32;">'+count+"</font>秒");
		if (count == 0) {
			$("#phone_code").html('<a href="javascript:;" onclick="peSubmit();" style="color:#a71e32; margin-top:0; text-decoration:underline"> 重新获取手机验证码</a>');
			clearInterval(countdown);
		}
		count--;
	}
}

</script></div>

<?php
include './application/views/common/zhs_footer.php';
?>

<?php
include './application/views/common/zhs_right.php';
?>


